perm filename INHERI.TEX[CLS,LSP] blob
sn#847173 filedate 1987-10-14 generic text, type C, neo UTF8
COMMENT ā VALID 00002 PAGES
C REC PAGE DESCRIPTION
C00001 00001
C00002 00002 REVISED ``INHERITANCE OF SLOTS AND SLOT OPTIONS'' SECTION:
C00022 ENDMK
Cā;
REVISED ``INHERITANCE OF SLOTS AND SLOT OPTIONS'' SECTION:
The set of the names of all slots accessible in an instance of a class
$C$ is the union of the sets of names of slots defined by $C$ and its
superclasses. At most one slot of a given name can be accessible in an
instance.
In the simplest case, only one class among $C$ and its superclasses
defines a slot with a given slot name. If a slot is defined by a
superclass of $C$, we say that the slot is inherited. The characteristics
of the slot are determined by the slot specifier of the defining class.
Consider the defining class for a slot $S$. If the {\bf :allocation} slot
option is omitted or its value is {\bf :instance}, then $S$ is a local
slot and each instance of $C$ has its own slot named $S$ that stores its
own value. If the value of the {\bf :allocation} slot option is {\bf
:class}, then $S$ is a shared slot, the class that defined $S$ stores the
value, and all instances of $C$ access that single slot.
In general, more than one class among $C$ and its superclasses can define
a slot with a given name. In such cases, only one slot with the given
name is accessible in an instance of $C$, and the characteristics of that
slot are a combination of the several slot specifiers, computed as
follows:
\beginlist
\item{\bull} All the slot specifiers for a given slot name are ordered
from most specific to least specific, according to the order in the class
precedence list of $C$ of the classes that define them.
\item{\bull} The allocation of a slot is controlled by the most specific
slot specifier. If the most specific slot specifier does not contain an
{\bf :allocation} slot option, {\bf :instance} is used. Less specific
slot specifiers never affect the allocation.
\item{\bull} The effective value for the {\bf :initform} option of a slot
is controlled by the most specific slot specifier that contains an {\bf
:initform} slot option. If no slot specifier contains an {\bf :initform}
slot option, the slot has no default initial value form.
\item{\bull}
The {\bf :type} option for $C$ is the value $T\sub 1$, and
the contents of the slot $S$ will always be of type
{\tt (and}~$T\sub 1$~$\ldots$~$T\sub n${\tt )}.
\item{\bull} The contents of a slot will always be of type {\tt
(and}~$T\sub 1$~$\ldots$~$T\sub n${\tt )} where $T\sub \ldots T\sub n$ are
the values of the {\bf :type} slot options contained in all of the slot
specifiers. If no slot specifier contains {\bf :type} slot option, the
contents of a slot will always be of type {\bf t}.
\endlist
The {\bf :reader} and {\bf :accessor} slot options create methods rather
than defining characteristics of a slot. Reader and accessor
methods are inherited in the sense described in the section ``Inheritance
of Methods.''
A consequence of the allocation rule is that a shared slot can be
shadowed. For example, if a class $C\sub 1$ defines a slot named $S$
whose value for the {\bf :allocation} slot option is {\bf :class}, that
slot is accessible in instances of $C\sub 1$ and all of its subclasses.
However, if $C\sub 2$ is a subclass of $C\sub 1$ and also defines a slot
named $S$, $C\sub 1$'s slot is not shared by instances of $C\sub 2$ and
its subclasses. See the slot named S2 in the class named C2 in the
section ``Examples of Inheritance.''
A consequence of the type rule is that the value of a slot satisfies the
type constraint of each slot specifier that contributes to that slot.
Note that an implementation may or may not choose to check the type of
the new value when initializing or assigning to a slot.
Methods that access slots know only the name of the slot and the type of
the slot's value. Suppose a superclass provides a method that expects
to access a shared slot of a given name and a subclass defines a local
slot with the same name. If the method provided by the superclass is
used on an instance of the subclass, the method accesses the local slot.
\endsubSection%{Examples of Inheritance}
\endSection%{Inheritance}